From a2cacdde16d80a3964df3b72162fdab99d1bff94 Mon Sep 17 00:00:00 2001 From: "cl349@firebug.cl.cam.ac.uk" Date: Tue, 13 Sep 2005 17:49:38 +0000 Subject: [PATCH] Switch memory target handling to use xstransact. Signed-off-by: Christian Limpach --- tools/python/xen/xend/XendDomain.py | 2 +- tools/python/xen/xend/XendDomainInfo.py | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py index 4c7f8250af..10917e2ab0 100644 --- a/tools/python/xen/xend/XendDomain.py +++ b/tools/python/xen/xend/XendDomain.py @@ -741,7 +741,7 @@ class XendDomain: @return: 0 on success, -1 on error """ dominfo = self.domain_lookup(id) - return dominfo.mem_target_set(mem) + return dominfo.setMemoryTarget(mem * (1 << 20)) def domain_vcpu_hotplug(self, id, vcpu, state): """Enable or disable VCPU vcpu in DOM id diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 89bd8e2f00..85f6abcdd8 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -158,7 +158,7 @@ class XendDomainInfo: log.debug('info=' + str(info)) log.debug('config=' + prettyprintstring(config)) - vm.memory = info['mem_kb']/1024 + vm.memory = info['mem_kb'] / 1024 vm.target = info['mem_kb'] * 1024 if config: @@ -213,7 +213,6 @@ class XendDomainInfo: DBVar('restart_state', ty='str'), DBVar('restart_time', ty='float'), DBVar('restart_count', ty='int'), - DBVar('target', ty='long', path="memory/target"), DBVar('device_model_pid', ty='int'), ] @@ -321,13 +320,19 @@ class XendDomainInfo: else: xstransact.Remove(self.path, "console/ring-ref") + def setMemoryTarget(self, target): + self.memory_target = target + if target: + xstransact.Write(self.path, "memory/target", "%i" % target) + else: + xstransact.Remove(self.path, "memory/target") + def update(self, info=None): """Update with info from xc.domain_getinfo(). """ self.info = info or dom_get(self.id) self.memory = self.info['mem_kb'] / 1024 self.ssidref = self.info['ssidref'] - self.target = self.info['mem_kb'] * 1024 def state_set(self, state): self.state_updated.acquire() @@ -643,7 +648,7 @@ class XendDomainInfo: self.memory = int(sxp.child_value(config, 'memory')) if self.memory is None: raise VmError('missing memory size') - self.target = self.memory * (1 << 20) + self.setMemoryTarget(self.memory * (1 << 20)) self.ssidref = int(sxp.child_value(config, 'ssidref')) cpu = sxp.child_value(config, 'cpu') if self.recreate and self.id and cpu is not None and int(cpu) >= 0: @@ -1035,14 +1040,6 @@ class XendDomainInfo: log.warning("Unknown config field %s", field_name) index[field_name] = field_index + 1 - def mem_target_set(self, target): - """Set domain memory target in bytes. - """ - if target: - self.target = target * (1 << 20) - # Commit to XenStore immediately - self.exportToDB() - def vcpu_hotplug(self, vcpu, state): """Disable or enable VCPU in domain. """ -- 2.30.2